package com.musicserver.controller;

import com.musicserver.common.R;
import com.musicserver.model.request.SongListRequest;
import com.musicserver.service.SongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class SongListController {
    @Autowired
    private SongListService songListService;
    /** 查询歌单列表，style 是歌单分类查询条件，该参数不传时查询所有分类歌单， */
    @GetMapping("/songList")
    public R songList(@RequestParam(required = false) String style) {
        return songListService.songList(style);
    }

    @PostMapping("/songList/add")
    public R addSongList(@RequestBody SongListRequest addSongListRequest) {
        return songListService.addSongList(addSongListRequest);
    }

    // 编辑歌单
    @PostMapping("/songList/update")
    public R updateSongListMsg(@RequestBody SongListRequest updateSongListRequest) {
        return songListService.updateSongListMsg(updateSongListRequest);
    }

    @DeleteMapping("/songList/delete")
    public R deleteSongList(@RequestParam int id) {
        return songListService.deleteSongList(id);
    }

    @DeleteMapping("/songList/deleteIds")
    public R deleteSongList(@RequestParam String[] id) {
        return songListService.deleteSongLists(id);
    }

    // 返回标题包含文字的歌单
    @GetMapping("/songList/likeTitle/detail")
    public R songListOfLikeTitle(@RequestParam String title) {
        return songListService.likeTitle(title);
    }

    // 返回指定类型的歌单
    @GetMapping("/songList/style/detail")
    public R songListOfStyle(@RequestParam String style) {
        return songListService.likeStyle(style);
    }

    // 返回歌单里指定歌单 ID 的歌曲
    @GetMapping("/songList/detail")
    public R listSongOfSongId(@RequestParam int songListId) {

        //TODO 这里需要调用 Service 接口返回实际数据
        return R.success("查询成功", null);
    }
}
